<?php if (!defined('THINK_PATH')) exit();?>﻿<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="/thinkphp2/Public/lib/html5shiv.js"></script>
    <script type="text/javascript" src="/thinkphp2/Public/lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="/thinkphp2/Public/static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="/thinkphp2/Public/static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="/thinkphp2/Public/lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="/thinkphp2/Public/static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="/thinkphp2/Public/static/h-ui.admin/css/style.css"/>
    <style>
        pre {
            text-align: left;
            display: block;
            font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
            padding: 9.5px;
            margin-bottom: 10px;
            font-size: 12px;
            line-height: 20px;
            word-break: break-all;
            word-wrap: break-word;
            white-space: pre;
            white-space: pre-wrap;
            background-color: inherit;
            border: none;
            border-radius: 4px;
            color: #333;
        }

        .pagination {
            margin: 20px 0;
        }

        .pagination ul {
            display: inline-block;
            list-style: none;
            *display: inline;
            /* IE7 inline-block hack */

            *zoom: 1;
            margin-left: 0;
            margin-bottom: 0;
            -webkit-border-radius: 4px;
            -moz-border-radius: 4px;
            border-radius: 4px;
            -webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
            -moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
            box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        }

        .pagination ul > li {
            display: inline;
        }

        .pagination ul > li > a,
        .pagination ul > li > span,
        .pagination #lastspan {
            float: left;
            padding: 4px 12px;
            line-height: 20px;
            text-decoration: none;
            background-color: #ffffff;
            border: 1px solid #dddddd;
            border-left-width: 0;
        }

        .pagination ul > li > span.current {
            background-color: #0b7ebf;
            color: #FFFFFF;
        }

        .pagination ul > li > a:hover,
        .pagination ul > li > a:focus,
        .pagination ul > .active > a,
        .pagination ul > .active > span {
            background-color: #f5f5f5;
        }

        .pagination ul > .active > a,
        .pagination ul > .active > span {
            color: #000;
            background-color: #0b7ebf;
            cursor: default;
        }

        .pagination ul > .disabled > span,
        .pagination ul > .disabled > a,
        .pagination ul > .disabled > a:hover,
        .pagination ul > .disabled > a:focus {
            color: #999999;
            background-color: transparent;
            cursor: default;
        }

        .pagination ul > li:first-child > a,
        .pagination ul > li:first-child > span {
            border-left-width: 1px;
            -webkit-border-top-left-radius: 4px;
            -moz-border-radius-topleft: 4px;
            border-top-left-radius: 4px;
            -webkit-border-bottom-left-radius: 4px;
            -moz-border-radius-bottomleft: 4px;
            border-bottom-left-radius: 4px;
        }

        .pagination ul > li:last-child > a,
        .pagination ul > li:last-child > span,
        .pagination #lastspan {
            -webkit-border-top-right-radius: 4px;
            -moz-border-radius-topright: 4px;
            border-top-right-radius: 4px;
            -webkit-border-bottom-right-radius: 4px;
            -moz-border-radius-bottomright: 4px;
            border-bottom-right-radius: 4px;
        }

        .pagination-centered {
            text-align: center;
        }

        .pagination-right {
            text-align: right;
        }

        .pagination-large ul > li > a,
        .pagination-large ul > li > span,
        .pagination-large #lastspan {
            padding: 11px 19px;
            font-size: 17.5px;
        }

        .pagination-large ul > li:first-child > a,
        .pagination-large ul > li:first-child > span {
            -webkit-border-top-left-radius: 6px;
            -moz-border-radius-topleft: 6px;
            border-top-left-radius: 6px;
            -webkit-border-bottom-left-radius: 6px;
            -moz-border-radius-bottomleft: 6px;
            border-bottom-left-radius: 6px;
        }

        .pagination-large ul > li:last-child > a,
        .pagination-large ul > li:last-child > span,
        .pagination-large #lastspan {
            -webkit-border-top-right-radius: 6px;
            -moz-border-radius-topright: 6px;
            border-top-right-radius: 6px;
            -webkit-border-bottom-right-radius: 6px;
            -moz-border-radius-bottomright: 6px;
            border-bottom-right-radius: 6px;
        }

        .pagination-mini ul > li:first-child > a,
        .pagination-small ul > li:first-child > a,
        .pagination-mini ul > li:first-child > span,
        .pagination-small ul > li:first-child > span {
            -webkit-border-top-left-radius: 3px;
            -moz-border-radius-topleft: 3px;
            border-top-left-radius: 3px;
            -webkit-border-bottom-left-radius: 3px;
            -moz-border-radius-bottomleft: 3px;
            border-bottom-left-radius: 3px;
        }

        .pagination-mini ul > li:last-child > a,
        .pagination-small ul > li:last-child > a,
        .pagination-mini ul > li:last-child > span,
        .pagination-small ul > li:last-child > span {
            -webkit-border-top-right-radius: 3px;
            -moz-border-radius-topright: 3px;
            border-top-right-radius: 3px;
            -webkit-border-bottom-right-radius: 3px;
            -moz-border-radius-bottomright: 3px;
            border-bottom-right-radius: 3px;
        }

        .pagination-small ul > li > a,
        .pagination-small ul > li > span {
            padding: 2px 10px;
            font-size: 11.9px;
        }

        .pagination-mini ul > li > a,
        .pagination-mini ul > li > span {
            padding: 0 6px;
            font-size: 10.5px;
        }

        .dataTables_wrapper .dataTables_filter {
            margin-bottom: 10px;
        }
    </style>
    <!--[if IE 6]>
    <script type="text/javascript" src="/thinkphp2/Public/lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>


    <![endif]-->
    <title>问题列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 问题管理 <span
        class="c-gray en">&gt;</span> 班组问题管理 <a class="btn btn-success radius r"
                                                style="line-height:1.6em;margin-top:3px"
                                                href="javascript:location.replace(location.href);" title="刷新"><i
        class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">

    <div class="text-c" id="filterDiv">
        <!--<button onclick="removeIframe()" class="btn btn-primary radius">关闭选项卡</button>-->
        <form action="<?php echo U('Index/issue/issue_list');?>" method="post" id="filterForm" name="filterForm">
	        <span class="select-box inline">
            <select name="sec_id" class="select">
                <option value="-1">--请选择工务段--</option>
                <?php if(is_array($sections)): foreach($sections as $key=>$vo): $selected=$vo['sec_id']==$params['sec_id']?"selected":"1"; ?>
                    <option value="<?php echo ($vo["sec_id"]); ?>" <?php echo ($selected); ?>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($vo["sec_name"]); ?></option><?php endforeach; endif; ?>
            </select>
             <select name="dep_id" class="select">
                 <option value="-1">--请选择科室--</option>
                 <?php if(is_array($deps)): foreach($deps as $key=>$vo): $selected=$vo['dep_id']==$params['dep_id']?"selected":"1"; ?>
                     <option value="<?php echo ($vo["dep_id"]); ?>" <?php echo ($selected); ?>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($vo["dep_name"]); ?></option><?php endforeach; endif; ?>
             </select>
            <select name="team_id" class="select">
                <option value="-1">--请选择班组--</option>
                <?php if(is_array($teams)): foreach($teams as $key=>$vo): $selected=$vo['team_id']==$params['team_id']?"selected":"1"; ?>
                    <option value="<?php echo ($vo["team_id"]); ?>" <?php echo ($selected); ?>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo ($vo["team_name"]); ?></option><?php endforeach; endif; ?>
            </select>

            </span> 日期范围：
            <input type="text" onfocus="WdatePicker({ maxDate:'#F{   $dp.$D(\'logmax\')||\'%y-%M-%d\'}' })" id="logmin" name="begintime"
                   class="input-text Wdate" style="width:185px;" value="<?php echo ($params['begintime']); ?>">
            -
            <input type="text" onfocus="WdatePicker({ minDate:'#F{   $dp.$D(\'logmin\')}',maxDate:'%y-%M-%d' })"
                   id="logmax"
                   value="<?php echo ($params['endtime']); ?>"
                   name="endtime"
                   class="input-text Wdate" style="width:185px;">
            <input type="text" name="issueregex" id="issueregex" placeholder="模糊搜索-请输入问题中包含的关键字" style="width:250px" class="input-text" value="<?php echo ($params['issueregex']); ?>">
            <button name="" class="btn btn-success radius" type="submit"><i class="Hui-iconfont">&#xe665;</i> 搜问题</button>
            <!--<button name="" id="exportExcel" class="btn btn-primary radius" type="button"><i class="icon Hui-iconfont">&#xe641;</i> 导出</button>-->
        </form>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20"><span class="l">
        <a href="javascript:;" onclick='batchDel("<?php echo U('Index/issue/issueBathDel');?>")'
                                                               class="btn btn-danger radius"><i class="Hui-iconfont">
        &#xe6e2;</i> 批量删除</a>
        <a class="btn btn-primary radius" data-title="批量导出" id="exportBt"
                    href="javascript:;"><i class="icon Hui-iconfont">&#xe641;</i>
        批量导出</a> <a class="btn btn-primary radius" data-title="添加问题"
                    onclick="article_add('添加问题','/thinkphp2/Index/Issue/issule_add.html','800','600')"
                    href="javascript:;"><i class="Hui-iconfont">&#xe600;</i>
        添加问题</a></span> <span class="r">共有数据：<strong><?php echo ($count); ?></strong> 条</span></div>
    <div class="mt-20">
        <table class="table table-border table-bordered table-bg table-hover table-sort">
            <thead>
            <tr class="text-c">
                <th width="25"><input type="checkbox" name="" value=""></th>
                <th width="80">ID</th>
                <th width="80">工务段</th>
                <th width="80">科室</th>
                <th width="80">班组</th>
                <th width="80">问题性质</th>
                <th width="120">內容</th>
                <th width="120">时间</th>
                <th width="120">操作</th>
            </tr>
            </thead>
            <tbody>


            <?php if(is_array($issues)): foreach($issues as $key=>$vo): ?><tr class="text-c">
                    <td><input type="checkbox" data-iid="<?php echo ($vo["id"]); ?>" name="xxx"></td>
                    <td><?php echo ($vo["id"]); ?></td>
                    <td class="text-center"><?php echo ($vo["sec_name"]); ?></td>
                    <td><?php echo ($vo["dep_name"]); ?></td>
                    <td><?php echo ($vo["team_name"]); ?></td>
                    <?php if($vo["issuetype_id"] == 2): ?><td><font color="#ff4500">共性问题</font></td>
                        <?php else: ?>
                        <td><font color="#483d8b" >个性问题</font></td><?php endif; ?>
                    <td>
                        <pre><?php echo ($vo["text"]); ?></pre>
                    </td>
                    <td><?php echo (date("Y-m-d",$vo["time"])); ?></td>
                    <td class="f-14 td-manage"><a
                            style="text-decoration:none" class="ml-5"
                            onClick="article_edit('问题编辑','/thinkphp2/Index/Issue/issue_edit.html?id=<?php echo ($vo["id"]); ?>','10001')" href="javascript:;" title="编辑"><i
                            class="Hui-iconfont">&#xe6df;</i></a> <a style="text-decoration:none" class="ml-5"
                                                                     onClick='article_del(this,"<?php echo U('Index/Issue/issue_del',array('id'=>$vo['id']));?>")'
                        href="javascript:;"
                        title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>
                    </td>
                </tr><?php endforeach; endif; ?>
            </tbody>
        </table>
        <!-- <div class="pagination"><?php echo ($page); ?></div>-->
        <div class="pagination" align="right"><?php echo ($page); ?></div>
    </div>

</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/thinkphp2/Public/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/thinkphp2/Public/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/thinkphp2/Public/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/thinkphp2/Public/static/h-ui.admin/js/H-ui.admin.js"></script>
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/thinkphp2/Public/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="/thinkphp2/Public/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="/thinkphp2/Public/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">

    function batchDel(url){
        var del_ids = [];
        $.each($('input[name="xxx"]:checked'),function(key, value){
           del_ids.push($(value).data("iid"));
        });
        $.ajax({
            type: 'POST',
            url: url,
            dataType: 'json',
            data:JSON.stringify(del_ids),
            contentType: 'application/json',
            success: function (data) {
                layer.msg('已删除!', {icon: 1, time: 500}, function () {
                    window.location.reload();
                });
            },
            error: function (data) {
                console.log(data.msg);
            },
        });
    }
    $(function () {
        $("#filterDiv").delegate("select.select", "change", function () {
            var selected = $(this).val();
            console.log(selected);
        });

        $("#exportBt").on("click",function(){
            var tmpForm = "<form action='" + "<?php echo U('Index/index/expIssue');?>" +  "' method='post'>";
            var data = $("#filterForm").serialize();
            console.log("data: " + data);
            var datas =  data.split("&");
            console.log("datas: " + datas);
            $.each(datas, function(key, value){
               if(value){
                   var pair = value.split('=');
                   console.log(pair[0] + ": " + pair[1]);
                   if(pair[0] && pair[1]){
                       if(pair[0] == 'issueregex'){
                           pair[1] = decodeURIComponent(pair[1]);
                           console.log(pair[1]);
                       }
                       tmpForm += "<input type='text' name='" +  pair[0]  + "' value='" + pair[1] + "'/>";
                   }
               }
            });
            tmpForm +=  "</form>";
            var $form = $(tmpForm);
            $("body").append($form);
            $form.submit().remove();
        });
    });


    $('.table-sort').dataTable({
        "aaSorting": [[4, "desc"]],//默认第几个排序
        "bStateSave": true,//状态保存
        "bPaginate": false,
        "bInfo": false,
        "bSort":false,
//        "aoColumnDefs": [
//            //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
//            {"orderable": false, "aTargets": [0, 7]}// 不参与排序的列
//        ],
        "bFilter": false, //过滤功能
        oLanguage: {
            "sSearch": "从当前数据中检索: ",
        }
    });

    /*管理员-角色-添加*/
    function admin_role_add(title, url, w, h) {
        layer_show(title, url, w, h);
    }
    /*管理员-角色-编辑*/
    function admin_role_edit(title, url, id, w, h) {
        layer_show(title, url, w, h);
    }

    /*问题-添加*/
    function article_add(title, url, w, h) {
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    /*问题-编辑*/
    function article_edit(title, url, id, w, h) {
        console.log(url);
        var index = layer.open({
            type: 2,
            title: title,
            content: url
        });
        layer.full(index);
    }
    /*问题-删除*/
    function article_del(obj, url) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                type: 'GET',
                url: url,
                dataType: 'json',
                contentType: 'application/json',
                success: function (data) {
                    $(obj).parents("tr").remove();
                    layer.msg('已删除!', {icon: 1, time: 500}, function () {
                        window.location.reload();
                    });
                },
                error: function (data) {
                    console.log(data.msg);
                },
            });
        });
    }

    /*问题-审核*/
    function article_shenhe(obj, id) {
        layer.confirm('审核文章？', {
                    btn: ['通过', '不通过', '取消'],
                    shade: false,
                    closeBtn: 0
                },
                function () {
                    $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_start(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
                    $(obj).remove();
                    layer.msg('已发布', {icon: 6, time: 1000});
                },
                function () {
                    $(obj).parents("tr").find(".td-manage").prepend('<a class="c-primary" onClick="article_shenqing(this,id)" href="javascript:;" title="申请上线">申请上线</a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-danger radius">未通过</span>');
                    $(obj).remove();
                    layer.msg('未通过', {icon: 5, time: 1000});
                });
    }
    /*问题-下架*/
    function article_stop(obj, id) {
        layer.confirm('确认要下架吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="article_start(this,id)" href="javascript:;" title="发布"><i class="Hui-iconfont">&#xe603;</i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已下架</span>');
            $(obj).remove();
            layer.msg('已下架!', {icon: 5, time: 1000});
        });
    }

    /*问题-发布*/
    function article_start(obj, id) {
        layer.confirm('确认要发布吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="article_stop(this,id)" href="javascript:;" title="下架"><i class="Hui-iconfont">&#xe6de;</i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已发布</span>');
            $(obj).remove();
            layer.msg('已发布!', {icon: 6, time: 1000});
        });
    }
    /*问题-申请上线*/
    function article_shenqing(obj, id) {
        $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">待审核</span>');
        $(obj).parents("tr").find(".td-manage").html("");
        layer.msg('已提交申请，耐心等待审核!', {icon: 1, time: 2000});
    }

</script>
</body>
</html>